//
//  ViewController.m
//  SimpleLogIn
//
//  Created by dllo on 16/5/11.
//  Copyright © 2016年 jcl. All rights reserved.
//

#import "ViewController.h"
#import "VC2.h"
#import "SimpleModal.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
//    self.view.backgroundColor = [UIColor blueColor];
    [self creatView];
    [self createBarbuttonItem];
}

- (void)creatView {
    
    UIView *view = [[UIView alloc] initWithFrame:self.view.bounds];
    
    [self.view addSubview:view];
    
    [view release];
    
    UITextField *textOfUser = [[UITextField alloc]initWithFrame:CGRectMake(100, 100, 130, 40)];
    
//    textOfUser.center = view.center;
    
    textOfUser.placeholder = @"请输入用户名";
    
    [view addSubview:textOfUser];
    
    [textOfUser release];
    
    UITextField *textOfPassword = [[UITextField alloc]initWithFrame:CGRectMake(100, 160, 130, 40)];
    
//    textOfPassword.center = view.center;
    
    textOfPassword.placeholder = @"请输入密码";
    
    [view addSubview:textOfPassword];
    
    [textOfPassword release];
    
    
    UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(150, 300, 60, 40)];
    
    [button setTitle:@"登录" forState:UIControlStateNormal];
    
    [self.view addSubview:button];
    
    button.backgroundColor = [UIColor blueColor];
    
    [button addTarget:self action:@selector(handleLogIn:) forControlEvents:UIControlEventTouchUpInside];
    
}


- (void)handleLogIn:(UIButton *)login {
    
    VC2 *vc2 = [[VC2 alloc] init];
    
    
    [self.navigationController pushViewController:vc2 animated:YES];
    
    
    
    
    
}




- (void)createBarbuttonItem {
    
    
    self.navigationItem.title = @"登录";
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(handleAdd:)];
    
    
  
    
    
}

- (void)handleAdd:(UIBarButtonItem *)add {
    
    
    SimpleModal *modal = [[SimpleModal alloc] init];
    
    
    
    [self presentViewController:modal animated:YES completion:^{
        
        modal.navigationItem.title = @"注册";
        
        modal.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:modal action:@selector(handleCancel:)];
        
    }];
    
    
    
    
    
    
    
    
}






@end
